package la.bbs558.strategy.base;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Classname Factory
 * @Description 策略工厂
 * @Date 2023/2/22 10:07
 * @Created by weihanmin
 */
@Configuration
@Slf4j
public class StrategyFactory {

    public static Map<StrategyEnum,Strategy> strategyMap = new ConcurrentHashMap<>();

    public static Optional<Strategy> get(StrategyContext context){
        return context.getStrategyEnum().map(anEnum -> strategyMap.get(anEnum));
    }

}
